------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  E:\REStat_MS14767_Vol96(2)\Data preparation Compustat\5_raw_rjv_panel_america.log
  log type:  text
 opened on:  18 Dec 2014, 10:11:03

. *-----------------------------------------------------------------
. 
. ****************************************
. * This short file  drops non-american firms
. * from the RJV data set as well as observations from 1985
. * and entries without ticker.
. ****************************************
. 
. 
. *************
. * generate inside/outside dummy
. *************
. 
. use "raw_rjv_panel.dta", clear

. gen ins=0

. replace ins=1 if year>= eyear
(92265 real changes made)

. replace ins=0 if year> xyear
(12360 real changes made)

. 
. *************
. *we drop all infos from 1985 (we do not have COMPUSTAT data for that year)
. *************
. 
. count if year==1985
14016

. * 14016
. drop if year==1985
(14016 observations deleted)

. 
. 
. *************
. *we drop all firms that have no ticker (we cannot use them in the market share analysis)
. *************
. 
. count if ticker==""
112560

. * 112560
. 
. drop if ticker==""
(112560 observations deleted)

. 
. so ticker year

. merge ticker year using "ticker_country.dta"
variables ticker year do not uniquely identify observations in the master data

. tab _merge

     _merge |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        420        0.10        0.10
          2 |    317,968       79.17       79.27
          3 |     83,244       20.73      100.00
------------+-----------------------------------
      Total |    401,632      100.00

. 
. *****************************************************************
. * 
. *      _merge |      Freq.     Percent        Cum.
. * ------------+-----------------------------------
. *           1 |        420        0.10        0.10
. *           2 |    317,968       79.17       79.27
. *           3 |     83,244       20.73      100.00
. * ------------+-----------------------------------
. *       Total |    401,632      100.00
. *
. * 
. * _merge==1 : it is that 9 firms that appear in RJV-database with ticker
. * but have no counterpart in compustat.
. *************
. 
. drop if _merge==2
(317968 observations deleted)

. drop _merge

. 
. *************
. * here we drop all firms that are not american
. *************
. 
. count if countryinc!=0
14182

. * 14182
. 
. drop if countryinc!=0
(14182 observations deleted)

. 
. 
. *-*-*-*-*-*-* NOTE - DATA CORRECTION!!! *-*-*-*-*-*-*-*-*-*
. 
. ******* 
. * here we have to correct for the fact that for each entityname (connected to the TICKER)
. * there might be several entrynames.
. * we assume that the "mother" firm is in the RJV if at least one of the entitynames is in that RJV
. * we then keep only one observation per entityname, RJV, year.
. *************
. 
. egen ins2=max(ins), by(comnum rjvnum year)

. drop ins

. rename ins2 ins

. count if rjvnum==rjvnum[_n-1] & year==year[_n-1] & comnum==comnum[_n-1]
 1632

. * 1640
. drop if rjvnum==rjvnum[_n-1] & year==year[_n-1] & comnum==comnum[_n-1]
(1632 observations deleted)

. 
. *-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*-*-*
. 
. desc

Contains data from raw_rjv_panel.dta
  obs:        67,850                          
 vars:            16                          18 Dec 2014 10:10
 size:    25,783,000                          
------------------------------------------------------------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
------------------------------------------------------------------------------------------------------------------------------------------
rjvname         str161  %161s                 RJVNAME
entryname       str100  %100s                 ENTRYNAME
entityname      str76   %76s                  ENTITYNAME
ticker          str8    %9s                   TICKER
jv_year         int     %8.0g                 JV_YEAR
eyear           int     %8.0g                 EYEAR
xyear           int     %8.0g                 XYEAR
sic4            int     %8.0g                 SIC4
nonprofit       byte    %8.0g                 NONPROFIT
foreign1        str5    %9s                   FOREIGN1
foreign         float   %9.0g                 
rjvnum          float   %9.0g                 group(rjvname)
comnum          float   %9.0g                 group(entityname)
year            float   %9.0g                 
countryinc      byte    %10.0g                Country of Incorporation
ins             float   %9.0g                 
------------------------------------------------------------------------------------------------------------------------------------------
Sorted by:  
     Note:  dataset has changed since last saved

. 
. * obs:        67,842                          
. * vars:           16 
. 
. save raw_rjv_panel_america.dta, replace
file raw_rjv_panel_america.dta saved

. log close
      name:  <unnamed>
       log:  E:\REStat_MS14767_Vol96(2)\Data preparation Compustat\5_raw_rjv_panel_america.log
  log type:  text
 closed on:  18 Dec 2014, 10:11:06
------------------------------------------------------------------------------------------------------------------------------------------
